EqualCollections Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Determines if the two collections contain "equal" items in the same order. The passed BinaryPredicate is used to determine if two items are "equal".

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static bool EqualCollections<T>(
	IEnumerable<T> collection1,
	IEnumerable<T> collection2,
	BinaryPredicate<T> predicate
)
Visual Basic (Declaration)
Public Shared Function EqualCollections(Of T) ( _
	collection1 As IEnumerable(Of T), _
	collection2 As IEnumerable(Of T), _
	predicate As BinaryPredicate(Of T) _
) As Boolean
Visual C++
public:
generic<typename T>
static bool EqualCollections (
	IEnumerable<T>^ collection1, 
	IEnumerable<T>^ collection2, 
	BinaryPredicate<T>^ predicate
)

Parameters

collection1
IEnumerable<(Of <T>)>
The first collection to compare.
collection2
IEnumerable<(Of <T>)>
The second collection to compare.
predicate
BinaryPredicate<(Of <T>)>
The BinaryPredicate used to compare items for "equality". This predicate can compute any relation between two items; it need not represent equality or an equivalence relation.

Return Value

True if predicatereturns true for each corresponding pair of items in the two collections. If both collections are empty, true is returned.

Type Parameters

T
The type of items in the collections.

Remarks

Since an arbitrary BinaryPredicate is passed to this function, what is being tested for need not be equality. For example, the following code determines if each integer in list1 is less than or equal to the corresponding integer in list2.
 Copy imageCopy Code
            List<int> list1, list2;
            if (EqualCollections(list1, list2, delegate(int x, int y) { return x <= y; }) {
                // the check is true...
            }
            

Exceptions

ExceptionCondition
System..::ArgumentNullExceptioncollection1, collection2, or predicate is null.

See Also